package com.yike.user.service.impl;

import com.yike.user.entity.ShopBindingApply;
import com.yike.user.mapper.ShopBindingApplyMapper;
import com.yike.user.service.ShopBindingApplyService;
import com.yike.user.param.ShopBindingApplyPageParam;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yike.common.base.BaseServiceImpl;
import com.yike.common.pagination.Paging;
import com.yike.common.pagination.PageInfo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.transaction.annotation.Transactional;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * 店铺绑定申请表 服务实现类
 *
 * @author Sakura
 * @since 2024-09-03
 */
@Slf4j
@Service
public class ShopBindingApplyServiceImpl extends BaseServiceImpl<ShopBindingApplyMapper, ShopBindingApply> implements ShopBindingApplyService {

    @Autowired
    private ShopBindingApplyMapper shopBindingApplyMapper;

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean saveShopBindingApply(ShopBindingApply shopBindingApply) throws Exception {
        return super.save(shopBindingApply);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean updateShopBindingApply(ShopBindingApply shopBindingApply) throws Exception {
        return super.updateById(shopBindingApply);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public boolean deleteShopBindingApply(Long id) throws Exception {
        return super.removeById(id);
    }

    @Override
    public Paging<ShopBindingApply> getShopBindingApplyPageList(ShopBindingApplyPageParam shopBindingApplyPageParam) throws Exception {
        Page<ShopBindingApply> page = new PageInfo<>(shopBindingApplyPageParam, OrderItem.desc(getLambdaColumn(ShopBindingApply::getCreateTime)));
        LambdaQueryWrapper<ShopBindingApply> wrapper = new LambdaQueryWrapper<>();
        IPage<ShopBindingApply> iPage = shopBindingApplyMapper.selectPage(page, wrapper);
        return new Paging<ShopBindingApply>(iPage);
    }

}
